<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>await表达式</title>
  </head>
  <body>
    <script>
      const p = Promise.reject("失败了");

      // await要放在async函数中
      async function main() {
        let result = await p;
        // console.log(result);
      }

      // 调用函数
      main().then(
        value => {
          console.log(value);
        },
        reason => {
          console.log(reason);
        }
      );
    </script>
  </body>
</html>
